<?php
/**
 * QFSHOP 
 * ============================================================================
 * 青峰网络科技有限公司，并保留所有权利。
*/

define('IN_ZYS', true);
require(dirname(__FILE__) . '/includes/init.php');

//配送方式


/*配送列表*/
if($_REQUEST['act']=='list'){
	$sql = "SELECT * FROM ".ly()."shipping";
	$row=$db->getAll($sql);
    $smarty->assign('shipping_list',$row);
    $smarty->display('shipping_list.html');
}
//编辑与修改页面
elseif($_REQUEST['act']=='edit'){
	$id=$_REQUEST['id'];
	if($id==''){
		$smarty->display('shipping_edit.html');
	}else{
		$sql="select * from ".ly()."shipping where shipping_id='{$id}'";
		$row=$db->getRow($sql);
		$smarty->assign('edit',$row);
		$smarty->display('shipping_edit.html');
	}
}
//编辑与修改功能
elseif($_REQUEST['act']=='insert'){
	$shipping_id=$_POST['shipping_id'];
	$shipping_name=$_POST['shipping_name'];
	$shipping_desc=$_POST['shipping_desc'];
	$support_cod=$_POST['support_cod'];
	$shipping_order=$_POST['shipping_order'];
	if($shipping_id){
		$sql="update ".ly()."shipping set shipping_name='{$shipping_name}', shipping_desc='{$shipping_desc}', support_cod='{$support_cod}', shipping_order='{$shipping_order}' where shipping_id='{$shipping_id}'";
	}else{
		$sql="insert into " .ly()."shipping (shipping_name,shipping_desc,support_cod,shipping_order)values('{$shipping_name}','{$shipping_desc}','{$support_cod}','{$shipping_order}')";
	}
	$row=$db->query($sql);
		if($row){
			$href[]=array('text'=>"返回配送列表",'href'=>'shipping.php?act=list');
         sys_msg("操作成功！",$href);
     	}else{
     		$href[]=array('text'=>"重新编辑",'href'=>'shipping.php?act=edit');
         sys_msg("操作失败！",$href);
     	}
}
//删除功能
elseif($_REQUEST['act']=='del'){
	$id=$_REQUEST['id'];
	$sql="delete from ".ly()."shipping where shipping_id='{$id}'";
	$row=$db->query($sql);
		if($row){
			$href[]=array('text'=>"返回配送列表",'href'=>'shipping.php?act=list');
         sys_msg("操作成功！",$href);
     	}else{
     		$href[]=array('text'=>"返回配送列表",'href'=>'shipping.php?act=list');
         sys_msg("操作失败！",$href);
     	}
}
